using System.Data;
using System.Data.SqlClient;

namespace SouthernLand.Common.DAL
{
    public class VisitorDAL : BaseDAL
    {
        public int Update()
        {
            using (SqlConnection myConn = GetConnectionString())
            {
                var myCommand = new SqlCommand("Job_Visitor_Update", myConn);
                myCommand.CommandType = CommandType.StoredProcedure;
                myCommand.ExecuteNonQuery();
                myConn.Close();
                return 1;
            }
        }

        public int GetVisitorNumber()
        {
            using (SqlConnection myConn = GetConnectionString())
            {
                try
                {
                    int value = 0;
                    var myCommand = new SqlCommand("Job_Visitor_GetVisitorNumber", myConn);
                    myCommand.CommandType = CommandType.StoredProcedure;
                    value = (int) myCommand.ExecuteScalar();
                    myConn.Close();
                    return value;
                }
                catch
                {
                    return 0;
                }
            }
        }
    }
}